<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="/sys-admin/css/general.css" rel="stylesheet" type="text/css">
<link href="/sys-admin/css/main.css" rel="stylesheet" type="text/css">
<script src="/sys-admin/js/jquery.js" type="text/javascript"></script>
</head>
<body>
<h1>
<span class="action-span"><a href="/sys-admin/action/goods/category.php?met=addui">添加父分类</a></span>
<span class="action-span1">商品分类管理</span>
</h1>
<div class="list-div">
<table cellpadding="2" cellspacing="1" width="100%">
  <tbody><tr>
    <th>编号</th>
    <th>名称</th>
    <th width="5%">单位</th>
    <th width="5%">导航栏显示</th>
    <th width="5%">是否显示</th>
    <th width="10%">排序</th>
    <th width="20%">操作</th>
  </tr>
  <{foreach from=$categorys item=category}>
  <tr id="c_<{$category.cat_id}>">
    <td class="num"><{$category.cat_id}></td>
    <td class="fwb">
    	<img src="/sys-admin/images/menu_minus.gif">
        <span><a href=""><{$category.cat_name}></a></span>
    </td>
    <td><{$category.cat_unit}></td>
    <td><{if $category.is_show_nav == 1}><img src="/sys-admin/images/yes.gif"><{else}><img src="/sys-admin/images/no.gif"><{/if}></td>
    <td><{if $category.is_show == 1}><img src="/sys-admin/images/yes.gif"><{else}><img src="/sys-admin/images/no.gif"><{/if}></td>
    <td><{$category.sort_order}></td>
    <td>
      <a href="/sys-admin/action/goods/category.php?met=editui&id=<{$category.cat_id}>">编辑</a> |
      <a href="javascript:delCategory('<{$category.cat_name}>',<{$category.cat_id}>);">移除</a> |
      <a href="/sys-admin/action/goods/category.php?met=addui&pid=<{$category.cat_id}>">加子分类</a>
    </td>
  </tr>
  <{if $category.childs|@count gt 0}>
	  <{foreach from=$category.childs item=child1}>
	  <tr id="c_<{$category.cat_id}>_<{$child1.cat_id}>">
	    <td class="num"><{$child1.cat_id}></td>
	    <td class="fwb">
	        <span class="pl15"></span>
	    	<img src="/sys-admin/images/menu_minus.gif">
	        <span><a href=""><{$child1.cat_name}></a></span>
	    </td>
	    <td><{$child1.cat_unit}></td>
	    <td><{if $child1.is_show_nav == 1}><img src="/sys-admin/images/yes.gif"><{else}><img src="/sys-admin/images/no.gif"><{/if}></td>
	    <td><{if $child1.is_show == 1}><img src="/sys-admin/images/yes.gif"><{else}><img src="/sys-admin/images/no.gif"><{/if}></td>
	    <td><{$child1.sort_order}></td>
	    <td>
	      <a href="/sys-admin/action/goods/category.php?met=editui&id=<{$child1.cat_id}>">编辑</a> |
	      <a href="javascript:delCategory('<{$child1.cat_name}>',<{$child1.cat_id}>);">移除</a> |
	      <a href="/sys-admin/action/goods/category.php?met=addui&pid=<{$child1.cat_id}>">加子分类</a>
	    </td>
	  </tr>
	  <{if $child1.childs|@count gt 0}>
	  	  <{foreach from=$child1.childs item=child2}>
		  <tr id="c_<{$category.cat_id}>_<{$child1.cat_id}>_<{$child2.cat_id}>">
		    <td class="num"><{$child2.cat_id}></td>
		    <td class="fwb">
		        <span class="pl30"></span>
		    	<img src="/sys-admin/images/menu_minus.gif">
		        <span><a href=""><{$child2.cat_name}></a></span>
		    </td>
		    <td><{$child2.cat_unit}></td>
		    <td><{if $child2.is_show_nav == 1}><img src="/sys-admin/images/yes.gif"><{else}><img src="/sys-admin/images/no.gif"><{/if}></td>
		    <td><{if $child2.is_show == 1}><img src="/sys-admin/images/yes.gif"><{else}><img src="/sys-admin/images/no.gif"><{/if}></td>
		    <td><{$child2.sort_order}></td>
		    <td>
		      <a href="/sys-admin/action/goods/category.php?met=editui&id=<{$child2.cat_id}>">编辑</a> |
		      <a href="javascript:delCategory('<{$child2.cat_name}>',<{$child2.cat_id}>);">移除</a>
		    </td>
		  </tr>
		  <{/foreach}>
	  <{/if}>
	  <{/foreach}>
  <{/if}>
  <{/foreach}>
  </tbody></table>
</div>
<script type="text/javascript">
function delCategory(name,id){
	if(confirm("您确定要删除'"+name+"'?")){
		$.get('/sys-admin/action/goods/category.php?met=delete&id='+id+'&t='+(new Date().getTime()),null,function(result){
			if($.trim(result) == "1"){
				alert("删除'"+name+"'成功");
				document.location.reload();
			}else if($.trim(result) == "2"){
				alert("存在子分类，请先移除子分类");
			}else{
				alert("删除'"+name+"'失败");
			}
		});
	}
}
</script>
</body></html>